<extend name="public@base5"/>
<script>
    function validateInput(input) {
  if (input.value.length > 11) {
    input.value = input.value.slice(0, 11);
  }
  alert("11")
}
</script>
<block name="main">
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active">{:lang('USER_ADMININDEX_INDEX')}</a>
            </li>
        </ul>
        <div class="card margin-top-20">
            <div class="card-body">
                <form class="row gap-1 g-3 align-items-center" method="get" action="{:url('admin/UserList/index')}">
                    <div class="col-2">
                        <input class="form-control" type="text" name="uid" value="{:input('request.uid')}" placeholder="{:lang('User ID')}">
                    </div>
                    <div class="col-2">
                        <!-- <input class="form-control" type="text" name="keyword" value="{:input('request.keyword')}"
                               placeholder="{:lang('USERNAME')}/{:lang('Nickname')}/{:lang('EMAIL')}/{:lang('MOBILE')}"> -->
                        <input class="form-control" type="text" name="mobile" value="{:input('request.mobile')}" placeholder="{:lang('MOBILE')}" maxlength="11">
                        <if condition="isset($mobile_error)">
                            <span class="text-danger">{$mobile_error}</span>
                        </if>   
                    </div>
                    <div class="col-2">
                        <select class="form-control form-check-inline" name="user_status" style="width: 140px;">
                            <php>$status_selected1=!empty($user_status)&&$user_status==1?"selected":"";</php>
                            <php>$status_selected2=!empty($user_status)&&$user_status==2?"selected":"";</php>
                            <option value='0'></option>
                            <option value='1' {$status_selected1}>正常</option>
                            <option value='2' {$status_selected2}>已封号</option>
                        </select>
                    </div>
                    <div class="col-6">
                        <select class="form-control form-check-inline" name="time_type" style="width: 140px;">
                            <php>$status_selected1=!empty($time_type)&&$time_type==1?"selected":"";</php>
                            <php>$status_selected2=!empty($time_type)&&$time_type==2?"selected":"";</php>
                            <php>$status_selected3=!empty($time_type)&&$time_type==3?"selected":"";</php>
                            <option value='1' {$status_selected1}>注册时间</option>
                            <option value='2' {$status_selected2}>登录时间</option>
                            <option value='3' {$status_selected3}>消费时间</option>
                        </select>:
                        <input type="text" class="js-bootstrap-date form-control form-check-inline" name="start_time"
                            value="{$start_time|default=''}"
                            style="width: 140px;" autocomplete="off">-
                        <input type="text" class="js-bootstrap-date form-control form-check-inline" name="end_time"
                            value="{$end_time|default=''}"
                            style="width: 140px;" autocomplete="off"> 
                        &nbsp;
                    </div>
                    <div class="col-2">
                        <input type="submit" class="btn btn-primary" value="{:lang('Search')}"/>
                        <a class="btn btn-danger" href="{:url('admin/UserList/index')}">{:lang('Clear')}</a>
                    </div>
                </form>
            </div>
        </div>
        <form method="post" class="js-ajax-form margin-top-20">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>{:lang('USERNAME')}</th>
                    <th>{:lang('Nickname')}</th>
                    <th>头像</th>
                    <th>兑换石</th>
                    <th>消费石</th>
                    <th>消费总额</th>
                    <th>{:lang('MOBILE')}</th>
                    <th>消费时间</th>
                    <th>注册时间</th>
                    <th>{:lang('LAST_LOGIN_TIME')}</th>
                    <th>{:lang('LAST_LOGIN_IP')}</th>
                    <th>{:lang('STATUS')}</th>
                    <th>{:lang('ACTIONS')}</th>
                </tr>
                </thead>
                <tbody>
                <php>
                    $user_statuses=array("0"=>'已封号',"1"=>'正常',"2"=>lang('USER_STATUS_UNVERIFIED'));
                </php>
                <foreach name="list" item="vo">
                    <tr>
                        <td>{$vo.user_id}</td>
                        <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:lang('THIRD_PARTY_USER'))}
                        </td>
                        <td>{$vo['user_nickname']?$vo['user_nickname']:lang('NOT_FILLED')}</td>
                        <td><img width="25" height="25" src="{:url('user/Public/avatar',array('id'=>$vo['id']))}"/></td>
                        <td>{$vo.score}</td>
                        <td>{$vo.coin}</td>
                        <td>{$vo.cost|default='0.00'}</td>
                        <td>{$vo.mobile}</td>
                        <td>{$vo['pay_time'] > 0 ? (date('Y-m-d H:i:s',$vo['pay_time'])) : ''}</td>
                        <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                        <td>{$vo['last_login_time'] > 0 ? (date('Y-m-d H:i:s',$vo['last_login_time'])) : ''}</td>
                        <td>{$vo.last_login_ip}</td>
                        <td>
                            <switch name="vo.user_status">
                                <case value="0">
                                    <span class="badge text-bg-danger">{$user_statuses[$vo['user_status']]}</span>
                                </case>
                                <case value="1">
                                    <span class="badge text-bg-success">{$user_statuses[$vo['user_status']]}</span>
                                </case>
                                <case value="2">
                                    <span class="badge text-bg-warning">{$user_statuses[$vo['user_status']]}</span>
                                </case>
                            </switch>
                        </td>
                        <td>
                            <neq name="vo.id" value="1">
                                <empty name="vo.user_status">
                                    <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                                       href="javascript:"
                                       data-href="admin/user/users/{$vo.id}/status/1"
                                       data-msg="您确定要解封此用户吗?"
                                       title="{:lang('ACTIVATE_USER')}"
                                       data-toggle="tooltip">
                                        <i class="fa fa-toggle-on fa-fw"></i></a>
                                    <else/>
                                    <a class="btn btn-xs btn-warning js-ajax-dialog-btn"
                                       href="javascript:"
                                       data-href="admin/user/users/{$vo.id}/status/0"
                                       data-msg="您确定要给此用户封号吗?"
                                       title="封号" data-toggle="tooltip">
                                        <i class="fa fa-toggle-off fa-fw"></i></a>
                                </empty>
                                <else/>
                                <span class="btn btn-xs btn-warning disabled"
                                      title="封号" data-toggle="tooltip">
                                <i class="fa fa-toggle-off fa-fw"></i>
                            </span>
                            </neq>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
            <div class="pagination">{$page}</div>
        </form>
    </div>
</block>
